<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;

$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
$basic=$this->plugin_setting('basic');
$return['banner']=$basic['image'];
$return['basic']=$basic;
if($_RQ['op']=='main'){
	//是否关注
	$return['isfollow']=pdo_getcolumn('core_fans',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'follow');
	$return['sum']=pdo_count('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'status'=>1,'isshow'=>1),'id');
	set_html('title','作品列表');
	$return['sharedata']=array(
		'title'=>'作品列表'.$basic['share_title'],
		'desc'=>'作品列表'.$basic['share_desc'],
		'link'=>custom_url('jy_vote/o_list/',true),
		'imgUrl'=>ATTACHMENT_URL.$basic['share_image'],
	);
	exi($return);
}
if($_RQ['op']=='o_detail'){
	if(!$_RQ['id']){
		exi('没有找到该作品，请重新选择！','error');
	}
	$opus=pdo_get('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	//进入作品详情，记录访问者浏览信息
	$islook=pdo_get('jy_vote_looklist',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	if(empty($islook)){
		$insert=array(
			'uniacid'=>$_SESSION['uniacid'],
			'oid'=>$_RQ['id'],
			'mid'=>$_SESSION['uid'],
			'createtime'=>TIMESTAMP
		
		);
		pdo_insert('jy_vote_looklist',$insert);
	}
	$opus['createtime']=date('Y-m-d H:i:s',$opus['createtime']);
	$return['opus']=$opus;
	exi($return);
}
if($_RQ['op']=='like'){
	
	if(!$_RQ['id']){
		exi('没有找到该作品，请重新选择！','error');
	}
	$like=$_RQ['like'];
	$opus=pdo_get('jy_vote_opus',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
	if($like==1){
		pdo_update('jy_vote_opus',array('like'=>$opus['like']+1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		pdo_update('jy_vote_looklist',array('islike'=>1),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
		
	}else{
		pdo_update('jy_vote_opus',array('like'=>$opus['like']-1),array('uniacid'=>$_SESSION['uniacid'],'id'=>$_RQ['id']));
		pdo_update('jy_vote_looklist',array('islike'=>0),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	}
	

}	
